package school.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import school.dao.SchoolDAO;
import school.domain.School;
import school.domain.Student;

public class SchoolTest {
	public static void main(String[] args) {
		SchoolDAO dao = SchoolDAO.getInstance();
		
		HashMap keywords = new HashMap();
		//keywords.put("schoolName", "경기고");
		keywords.put("schoolAddress", "서초구");
		List<School> schList = dao.selectSchoolDynamicIf(keywords);
		for(School ss : schList) {
			System.out.println(ss);
		}
		
		String[] schoolNames = {"경기고" ,"서초고"};
		HashMap map = new HashMap();
		map.put("names", schoolNames);
		System.out.println("------------학교이름들로 조회");
		schList = dao.selectDynamicForeach(map);
		for(School ss : schList) {
			System.out.println(ss);
		}
	
		
		
		
		School student1 = new School(102, "조경희", "서울시", "010-0000-0000", "개나리", 100);
		int cnt=0;
		
		//cnt = dao.insertSchoolSeq(student1);
	//	System.out.println("insert개수 : "+ cnt);
		
		//student1.setSchoolFlower("목련");
		//cnt = dao.updateSchool(student1);
	//	System.out.println("update개수 : " + cnt + "변경된 값 : " + student1.getSchoolFlower());
	
	//	cnt = dao.deleteSchoolById(100);
	//	System.out.println("삭제개수 : " + cnt);
		
	//	School listById = dao.sel ectSchoolById(1);
	//	System.out.println(listById);
		
		System.out.println("---------------전체조회------------");
		List<School> list = dao.selectSchoolList();
		for(School s : list) {
			System.out.println(s);
		}
		
		System.out.println("------------학생수가 1000~2000 인학교 ------------");
		list = dao.selectSchoolByEnrollmentRange(1000, 2000);
		for(School s : list){
			System.out.println(s);
		}
		System.out.println("-------------서울에 있는 학교 조회---------------");
		list = dao.selectSchoolByAddress("서울");
		for(School s : list){
			System.out.println(s);
		}
		
		System.out.println("-------------Student와 Join조회-------");
		School sch= dao.selectSchoolJoinStudent(1);
		System.out.println(sch);
		ArrayList<Student> stus = sch.getStudents();
		for(Student s : stus)	{
			System.out.println(s);
		}
		
	}
	
}
